package com.tencent.wxcloudrun.service.impl;

import com.tencent.wxcloudrun.constant.WxChatConstant;
import com.tencent.wxcloudrun.dto.WxSendTypeRequest;
import com.tencent.wxcloudrun.model.WeChatTemplateMsg;
import com.tencent.wxcloudrun.service.WxChatService;
import com.tencent.wxcloudrun.util.WxSendMessageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 下班推送策略
 */
@Service("OffWorkSend")
public class WxOffWorkSend implements WxChatService {

    @Autowired
    protected WxSendMessageUtils wxSendMessageUtils;

    @Override
    public void sendTest(WxSendTypeRequest request) {
        System.out.println("test: " + request.getType() + "_test: " + request.getOpenId());
        // 下班模板Id
        String templateId1 = WxChatConstant.templateId_1;
        // 模板参数
        Map<String, WeChatTemplateMsg> sendMag1 = new HashMap<String, WeChatTemplateMsg>();
        sendMag1.put("day", new WeChatTemplateMsg("你不孤单，有我早安。good morning露露~~~", "#7093DB"));
        sendMag1.put("day1", new WeChatTemplateMsg("给祖国的花朵，加油！！！", "#7093DB"));
        sendMag1.put("day2", new WeChatTemplateMsg("ヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノ", "#7093DB"));
        String send1 = wxSendMessageUtils.send(request.getOpenId(), templateId1, sendMag1);

        String templateId2 = WxChatConstant.templateId_2;
        Map<String, WeChatTemplateMsg> sendMag2 = new HashMap<String, WeChatTemplateMsg>();
        sendMag2.put("noon", new WeChatTemplateMsg("干饭了，干饭了!!!", "#CC3299"));
        sendMag2.put("noon1", new WeChatTemplateMsg("老板加蛋、加鸡腿", "#CC3299"));
        sendMag2.put("noon2", new WeChatTemplateMsg("ヽ(✿ﾟ▽ﾟ)ノ", "#CC3299"));
        String send2 = wxSendMessageUtils.send(request.getOpenId(), templateId2, sendMag2);

        String templateId3 = WxChatConstant.templateId_3;
        Map<String, WeChatTemplateMsg> sendMag3 = new HashMap<String, WeChatTemplateMsg>();
        sendMag3.put("dinner", new WeChatTemplateMsg("晚饭可以不吃提醒怎么能少~", "#FF6EC7"));
        sendMag3.put("dinner1", new WeChatTemplateMsg("逛逛超市和水果", "#FF6EC7"));
        sendMag3.put("dinner2", new WeChatTemplateMsg("ヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノ", "#FF6EC7"));
        String send3 = wxSendMessageUtils.send(request.getOpenId(), templateId3, sendMag3);

        String templateId4 = WxChatConstant.templateId_4;
        Map<String, WeChatTemplateMsg> sendMag4 = new HashMap<String, WeChatTemplateMsg>();
        sendMag4.put("night", new WeChatTemplateMsg("宝~要熄灯了，该去睡觉了哦，晚安~~~", "#FF6EC7"));
        sendMag4.put("night1", new WeChatTemplateMsg("每天都会定时提醒一下", "#FF6EC7"));
        sendMag4.put("night2", new WeChatTemplateMsg("ヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノ", "#FF6EC7"));
        String send4 = wxSendMessageUtils.send(request.getOpenId(), templateId4, sendMag4);
    }

    @Override
    public void sendTest1(WxSendTypeRequest request) {
        // 下班模板Id
        String templateId = WxChatConstant.templateId_1;
        // 模板参数
        Map<String, WeChatTemplateMsg> sendMag = new HashMap<String, WeChatTemplateMsg>();
        sendMag.put("day", new WeChatTemplateMsg("你不孤单，有我早安。good morning露露~~~", "#7093DB"));
        sendMag.put("day1", new WeChatTemplateMsg("给祖国的花朵，加油！！！", "#7093DB"));
        sendMag.put("day2", new WeChatTemplateMsg("ヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノ", "#7093DB"));

        String[] openIds = request.getOpenIds();
        if (openIds != null && openIds.length > 1) {
            for (String openId : openIds) {
                String send = wxSendMessageUtils.send(openId, templateId, sendMag);
            }
        } else {
            String send = wxSendMessageUtils.send(request.getOpenId(), templateId, sendMag);
        }
    }

    @Override
    public void sendTest2(WxSendTypeRequest request) {
        // 下班模板Id
        String templateId = WxChatConstant.templateId_2;
        // 模板参数
        Map<String, WeChatTemplateMsg> sendMag = new HashMap<String, WeChatTemplateMsg>();
        sendMag.put("noon", new WeChatTemplateMsg("干饭了，干饭了!!!", "#CC3299"));
        sendMag.put("noon1", new WeChatTemplateMsg("老板加蛋、加鸡腿", "#CC3299"));
        sendMag.put("noon2", new WeChatTemplateMsg("ヽ(✿ﾟ▽ﾟ)ノ", "#CC3299"));

        String[] openIds = request.getOpenIds();
        if (openIds != null && openIds.length > 1) {
            for (String openId : openIds) {
                String send = wxSendMessageUtils.send(openId, templateId, sendMag);
            }
        } else {
            String send = wxSendMessageUtils.send(request.getOpenId(), templateId, sendMag);
        }
    }

    @Override
    public void sendTest3(WxSendTypeRequest request) {
        // 下班模板Id
        String templateId = WxChatConstant.templateId_3;
        // 模板参数
        Map<String, WeChatTemplateMsg> sendMag = new HashMap<String, WeChatTemplateMsg>();
        sendMag.put("dinner", new WeChatTemplateMsg("晚饭可以不吃提醒怎么能少~", "#FF6EC7"));
        sendMag.put("dinner1", new WeChatTemplateMsg("逛逛超市和水果店", "#FF6EC7"));
        sendMag.put("dinner2", new WeChatTemplateMsg("ヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノ", "#FF6EC7"));

        String[] openIds = request.getOpenIds();
        if (openIds != null && openIds.length > 1) {
            for (String openId : openIds) {
                String send = wxSendMessageUtils.send(openId, templateId, sendMag);
            }
        } else {
            String send = wxSendMessageUtils.send(request.getOpenId(), templateId, sendMag);
        }
    }

    @Override
    public void sendTest4(WxSendTypeRequest request) {
        // 下班模板Id
        String templateId = WxChatConstant.templateId_4;
        // 模板参数
        Map<String, WeChatTemplateMsg> sendMag = new HashMap<String, WeChatTemplateMsg>();
        sendMag.put("night", new WeChatTemplateMsg("宝~要熄灯了，该去睡觉了哦，晚安~~~", "#FF6EC7"));
        sendMag.put("night1", new WeChatTemplateMsg("微信运动提醒的是你要休息了", "#FF6EC7"));
        sendMag.put("night2", new WeChatTemplateMsg("ヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノヽ(✿ﾟ▽ﾟ)ノ", "#FF6EC7"));

        String[] openIds = request.getOpenIds();
        if (openIds != null && openIds.length > 1) {
            for (String openId : openIds) {
                String send = wxSendMessageUtils.send(openId, templateId, sendMag);
            }
        } else {
            String send = wxSendMessageUtils.send(request.getOpenId(), templateId, sendMag);
        }
    }
}